from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from postion import options
from postion import service

driver = webdriver.Chrome(options=options,service=service)
driver.get(r'https://www.baidu.com/')
sleep(1)

driver.find_element(By.ID,'kw').send_keys('a6')
driver.find_element(By.ID,'su').click()
sleep(3)

# 设置滚动条距离顶部的位置，设置为 10000（最底部）
# js_down='var action=document.documentElement.scrollTop=10000'
# driver.execute_script(js_down)
# sleep(5)

# 设置滚动条距离顶部的位置，设置为 10000（最顶部）
# js_up= 'var action=document.documentElement.scrollTop=0'
# driver.execute_script(js_up)
# driver.quit()

#向下滚动
js_down='window.scrollTo(0,1000)'
driver.execute_script(js_down)
sleep(3)
#向上滚动
js_up='window.scrollTo(0,0)'
driver.execute_script(js_up)
sleep(3)
#向右滚动
js_right='window.scrollTo(0,1000)'
driver.execute_script(js_right)
sleep(3)
#向左滚动
js_left='window.scrollTo(0,0)'
driver.execute_script(js_left)
sleep(3)

driver.quit()